<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>

	</title>
	<style type="text/css">
		p{
			color: red;
		}
	</style>
</head>
<body>
用户名：	<input type="text" name="">
<p></p>
<script type="text/javascript">
	let input = document.querySelector('input')
	let p = document.querySelector('p')
	input.addEventListener('blur',function() {
		if(input.value == ''){
			p.innerText =  '用户名不能为空'
		}else if(input.value.length <5){
			p.innerText =  '显示用户格式不正确'
		}
	})
</script>
</body>
</html>